// pages/userCheckIn/userCheckIn.js
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
Page({
  data: {
    navtop:"",
    resdata:{},
    headimg:"",
  },
  onLoad(){
    const app =getApp();

    // 导航栏
    // 1.获取屏幕可使用宽度
    let windowWidth = wx.getSystemInfoSync().windowWidth;
    // 2.获取状态栏高度
    const statusBarHeight = wx.getSystemInfoSync().statusBarHeight;
    //3.获取胶囊按钮位置信息
    const menuButton = wx.getMenuButtonBoundingClientRect();
    this.setData({
      navtop:menuButton.top
    })
    this.getdata(app)

    this.setData({
      headimg:app.globalData.headimg
    },()=>{
      console.log(this.data.headimg);
    })
  },
  gitfor(){
    wx.navigateBack({
      delta: -1
    })
  },
  onChooseAvatar(e) {
    const { avatarUrl } = e.detail 
    this.setData({
      avatarUrl,
    })
  },
  dianjiqiandao(){
    const app =getApp();
    const that =this;
    wx.request({
      url: 'https://dj.ifankui.com/api/usr/checkin',
      method:'POST',
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      data:{
        openid:app.globalData.openid
      },
      success: (res) => {
        console.log(res);
        wx.showToast({
            title: res.data.msg,
            icon: 'none'
        });
        that.getdata(app)
      },
    })
  },

  getdata(app){
    const that =this;
    wx.request({
      url: 'https://dj.ifankui.com/api/usr/checkinInfo',
      method:"POST",
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      data:{
        openid:app.globalData.openid
      },
      success(res){
        that.setData({
            resdata:res
        })
      }
      

    })
  }
});